package com.demo.aop.pcut.stat;

import org.springframework.aop.ClassFilter;
import org.springframework.aop.support.StaticMethodMatcherPointcut;

import java.lang.reflect.Method;

/**
 * 描述：
 *
 * @author lida
 * @time 2019/10/23 11:44
 */
public class StaticPointcut extends StaticMethodMatcherPointcut {
	@Override
	public boolean matches(Method method, Class<?> targetClass) {
		return "sing".equals(method.getName());
	}

	/**
	 * lambda表达式相当于
	 * public ClassFilter getClassFilter(){
	 * 		return new ClassFilter(){
	 * 		 	public boolean matches(Class<?> clazz){
	 * 		 		return clazz == GoodPianist.class;
	 * 		 	}
	 * 		}
	 * }
	 * @return ClassFilter
	 */
	@Override
	public ClassFilter getClassFilter(){
		return clazz -> (clazz == GoodPianist.class);
	}
}
